package com.wt.bean;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created with IDEA
 * Describe:
 *          @ConﬁgurationProperties                 @Value
 * 功能       批量注入配置文件中的属性              一个个指定
 * 松散绑定         （松散语法） 支持                不支持
 * SpEL                不支持                         支持
 * JSR303数据校验       支持                          不支持
 * 复杂类型封装          支持                          不支持
 * Author:TianJi
 * Date:2018/9/30
 * Time:11:14
 */
@PropertySource(value={"classpath:person.properties"})                 //加载指定的配置文件
@Component
@ConfigurationProperties(prefix = "person") //默认是从全局配置文件中获取
public class Person {
   // @Value("${person.last-name}")
    private String lastName;

   // @Value("#{11*2}")
    private Integer age;

    //@Value("true")
    private boolean boss;

    private Date birth;

    private Map<String,Object> maps;
    private List<Object> lists;
    private Dog dog;

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public boolean isBoss() {
        return boss;
    }

    public void setBoss(boolean boss) {
        this.boss = boss;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }

    public Map<String, Object> getMaps() {
        return maps;
    }

    public void setMaps(Map<String, Object> maps) {
        this.maps = maps;
    }

    public List<Object> getLists() {
        return lists;
    }

    public void setLists(List<Object> lists) {
        this.lists = lists;
    }

    public Dog getDog() {
        return dog;
    }

    public void setDog(Dog dog) {
        this.dog = dog;
    }

    @Override
    public String toString() {
        return "Person{" +
                "lastName='" + lastName + '\'' +
                ", age=" + age +
                ", boss=" + boss +
                ", birth=" + birth +
                ", maps=" + maps +
                ", lists=" + lists +
                ", dog=" + dog +
                '}';
    }
}
